package xubo.wangcaifeng.love.Utils

import java.util

import redis.clients.jedis.{Jedis, JedisPool, JedisPoolConfig}


object JedisConnectionPool {

  val config = new JedisPoolConfig()
  config.setMaxTotal(20)
  config.setMaxIdle(10)
  config.setTestOnBorrow(true)
  val pool = new JedisPool(config, "mini1", 6379, 10000)

  def getConnection(): Jedis = {
    pool.getResource
  }

  def main(args: Array[String]): Unit = {

    val jedis = JedisConnectionPool.getConnection()

    val keys: util.Set[String] = jedis.keys("*")

    //val r = jedis.keys("*")
    //import scala.collection.JavaConversions._
    //for (p <- r) {
    //  println(p)
    //}

    val r = jedis.get("tzccfeth")

    println(r)

    jedis.close()
  }

}

